package com.shujia.seven;

import org.junit.Test;

import java.math.BigDecimal;

public class BigDecimalDemo {

    @Test
    public void test2() {
//        BigDecimal bd1 = new BigDecimal(0.05);
//        BigDecimal bd2 = new BigDecimal(0.01);
//        BigDecimal bd1 = new BigDecimal("0.05");
//        BigDecimal bd2 = new BigDecimal("0.01");

        BigDecimal bd1 = BigDecimal.valueOf(0.05);
        BigDecimal bd2 = BigDecimal.valueOf(0.01);
        BigDecimal add = bd1.add(bd2);
        System.out.println(add);

        BigDecimal bd3 = new BigDecimal("4.015");
        BigDecimal bd4 = new BigDecimal("100");
        System.out.println(bd3.multiply(bd4));
    }


    @Test
    public void test1() {
        System.out.println("0.05 + 0.01 = " + (0.05 + 0.01));
        System.out.println("1.0 - 0.42 = " + (1.0 - 0.42));
        System.out.println("4.015 * 100 = " + (4.015 * 100));
        System.out.println("123.3 / 100 = " + (123.3 / 100));

    }
}
